-module(logintest).

-export([login/0]).
-include("basetest.hrl").

-define(CONFIG,   "test.conf").
%-define(HOST,     "192.168.5.87").
%-define(PORT,     6001).
-define(REQBODY , "<Message />").

login() ->
    ReqMsg = basetest:init(5002, "zhangjun", "access", ?REQBODY),
        
    #config{host=Host,port=Port} = basetest:getconfig(?CONFIG),
    io:format("config host=~p port=~w~n", [Host,Port]),
   
    case gen_tcp:connect(Host, Port, [binary,{packet, 0}]) of
	{ok, Socket} ->
	    io:format("Socket=~p~n",[Socket]),
	    gen_tcp:send(Socket, ReqMsg),
	    Reply = basetest:wait_reply(Socket),
	    %log(Reply),
	    gen_tcp:close(Socket),
	    Reply;
	_ ->    
	    %io:format("connect fail~n"),
	    {error,peerconnfail}
    end.
